package com.pmcc.platform.salesman.web;

import com.pmcc.platform.salesman.entity.Salesman;
import com.pmcc.platform.salesman.service.SalesmanService;
import com.pmcc.platform.shop.service.ShopInfoService;
import com.pmcc.utils.AntPage;
import com.pmcc.utils.ApiResultBean;
import com.pmcc.utils.ResultBean;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: basePlatform
 * @description:
 * @author: Mr.Xue
 * @create: 2020-04-25 17:27
 **/
@RestController
@RequestMapping("api/v1/salesman")
public class SalesmanController {

    @Autowired
    SalesmanService salesmanService;

    @Autowired
    ShopInfoService shopInfoService;


    /**
     * 查询所有推广员
     *
     * @return
     */
/*    @RequestMapping(value = "/queryByPage", method = RequestMethod.GET)
    @ResponseBody
    public ResultBean list(Salesman salesman, AntPage antPage) {
        return salesmanService.queryByPage(salesman, antPage);
    }*/


    /**
     * 查询所有业务员
     *
     * @param antPage
     * @return
     */
    @RequestMapping(value = "/queryAllSalesman", method = RequestMethod.GET)
    @ResponseBody
    public ApiResultBean queryAllSalesman(AntPage antPage,String name,String phone) {

        return salesmanService.queryAllSalesman(antPage,name, phone);
    }


    /**
     * 添加业务员
     *
     * @param salesman
     * @return
     */
    @RequestMapping(value = "/addSalesman", method = RequestMethod.POST)
    @ResponseBody
    public ApiResultBean addSalesman(Salesman salesman) {

        return salesmanService.addSalesman(salesman);
    }


     /**
     * 删除业务员
     *
     * @param salesmanId
     * @return
     */
    @RequestMapping(value = "/deleteSalesman", method = RequestMethod.POST)
    @ResponseBody
    public ApiResultBean deleteSalesman(String salesmanId) {

        return salesmanService.deleteSalesman(salesmanId);
    }


    /**
     * 修改业务员信息
     *
     * @param salesman
     * @return
     */
    @RequestMapping(value = "/modifySalesman", method = RequestMethod.POST)
    @ResponseBody
    public ApiResultBean modifySalesman(Salesman salesman) {

        return salesmanService.modifySalesman(salesman);
    }

    /**
     * 查看当前的所有店铺
     * @param salesmanId
     * @return
     */
    @RequestMapping(value = "/lookShop", method = RequestMethod.GET)
    @ResponseBody
    public ApiResultBean lookShop(String salesmanId,AntPage antPage){
        return salesmanService.lookShop(salesmanId,antPage);
    }

    /**
     * 查看当前的所有导购
     * @param salesmanId
     * @return
     */
    @RequestMapping(value = "/lookShopping", method = RequestMethod.GET)
    @ResponseBody
    public ApiResultBean lookShopping(String salesmanId,AntPage antPage){
        return salesmanService.lookShopping(salesmanId,antPage);
    }

    /**
     * 店铺导购列表
     * @param shopId
     * @param antPage
     * @return
     */
    @RequestMapping(value = "/shopsList", method = RequestMethod.GET)
    @ResponseBody
    public ApiResultBean shopsList(String shopId,AntPage antPage){
        return  shopInfoService.shopsList(shopId,antPage);
    }


}
